package weavingdraft;
import java.awt.GridLayout;

import javax.swing.JPanel;

/**
 * The TieUp grid that allows the user to select from the tieup grid. 
 * @author Justin Wong
 *
 */
@SuppressWarnings("serial")
public class TieUpGrid extends JPanel{
	/**
	 * The WeavingDraft this object refers to. 
	 */
	private WeavingDraft my_draft;
	/**
	 * The size of this object. 
	 */
	private int size;
	/**
	 * Creates the object of the TieUpGrid. 
	 * @param the_draft the draft this object refers to. 
	 */
	public TieUpGrid(WeavingDraft the_draft){
		my_draft = the_draft;
		size = my_draft.getShortside();
		start();
	}
	/**
	 * Creates everything in this JPanel. 
	 */
	private void start(){
		this.setLayout(new GridLayout(size, size));
		createSquares();
		this.setVisible(true);
	}
	/**
	 * Creates all the squares for this JPanel. 
	 */
	private void createSquares(){
		for(int i = 0; i < size; i++){
			for(int j = 0; j < size; j++){
				TieUpSquare square = new TieUpSquare(i, j, this, my_draft);
				this.add(square);
			}
		}
	}
}
